<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="com.ignou.mca.beans.UserVO"%>
<%@page import="com.ignou.mca.datasource.DatabaseOperations"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.ignou.mca.beans.SubjectBean"%>
<%@page import="java.util.Iterator"%><html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="theme/style.css"
	media="screen" />
<title>OES - Subjects available to you</title>
	<script type='text/javascript'>
	function getExamList(subId)
	{
		window.location.href = 'DisplayExams.jsp?subject='+subId; 
	}
	
	</script>
</head>
<body>
	<div id="MainWrapper">
		<jsp:include page="header.jsp" /> 
		<jsp:include page="LeftContainer.jsp" />
		<div id="MainContent">
		<center>
			<h3>Subjects available</h3>
			<%
				UserVO uvo = (UserVO) session.getAttribute("UserVO");
				if(uvo==null)
				{
					response.sendRedirect("./Login.jsp");
				}
				else
				{
					DatabaseOperations dbOperations = new DatabaseOperations();
					ArrayList<SubjectBean> allSubs = dbOperations.getAllSubjects();
					session.setAttribute("Subjects", allSubs);
				%>
				<table align="center" width="100%" height="100%">	
				<%	
					Iterator<SubjectBean> itr = allSubs.iterator(); 
					while(itr.hasNext()) 
					{
						SubjectBean sb = (SubjectBean)itr.next();	
					%>
					<tr>
						<td><%= sb.getSubjectName() %></td>
						<td>  <a href="javascript: getExamList(<%=sb.getSubjectId() %>)">List Exams</a></td>
					</tr>
					<%
					}
					%>
					</table>
					<br><br>
					<br><br><br>
					<%
				}
			%>
		</center>
		</div>
		<jsp:include page="footer.jsp" />
	</div>
</body>
</html>